package cn.xorange.commons.utils.exception;

import java.util.Objects;

/**
 * @author : yangjian
 * @date : 2023/11/22
 * @description :
 */
public class BaseException extends RuntimeException{


    public BaseException(int status, int code, String message){
        this(status,code,message,null);
    }

    public BaseException(int status, int code, String message, Throwable throwable){
        this.status = status;
        this.code = code;
        this.message = message;
        if(Objects.nonNull(throwable)){
            super.setStackTrace(throwable.getStackTrace());
            this.because = ExceptionUtils.getCauseMsg(throwable);
        }
    }

    private int code;
    /** HTTP错误码 */
    private int status;
    /** 错误消息 */
    private String message;
    private String because;

    public int getCode() {
        return code;
    }
    public int getStatus(){
        return this.status;
    }
    @Override
    public String getMessage() {
        return this.message;
    }
    public String getBecause(){
        return this.because;
    }
}
